package com.fy.tt.entity.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fy.tt.util.JsonUtils;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
public class WordAndSemanticVo {
    // 词汇
    private Long wordId;

    private String name;

    private Long creatorId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date wordUpdateTime;

    private Long isTypeIn;

    private Long isRange;

    private Long status;

    private Long bandObjId;

    private String bandName;

    private String description;

    // 语义
    private String className;

    private String codeDescription;

    private String code;

    private List<Long> developerIds;

    private Long type;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date semanticUpdateTime;

    public WordAndSemanticVo(ResultSet rs) {
        try {
            this.wordId = rs.getLong("id");
            this.name = rs.getString("name");
            this.creatorId = rs.getLong("creator_id");
            this.wordUpdateTime = rs.getTimestamp("update_time");
            this.isTypeIn = rs.getLong("is_type_in");
            this.isRange = rs.getLong("is_range");
            this.status = rs.getLong("status");
            this.bandObjId = rs.getLong("band_obj_id");
            this.bandName = rs.getString("band_name");
            this.description = rs.getString("description");
            this.className = rs.getString("class_name");
            this.codeDescription = rs.getString("code_description");
            this.code = rs.getString("code");
            this.developerIds = JsonUtils.string2Array(rs.getString("developer_ids"));
            this.type = rs.getLong("type");
            this.semanticUpdateTime = this.wordUpdateTime = rs.getTimestamp(18);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
